home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / Chip_2004-11_cd1.bin / zkuste / planetaria / download / celestia / celestia-win32-1.3.2.exe / {app} / shaders / texphong_arb.vp < prev    next >
Text File  |  2004-03-23  |  2KB  |  69 lines

  1. !!ARBvp1.0
  2.  
  3. # Set up for phong shading fragment program.
  4.  
  5. ATTRIB iPos          = vertex.position;
  6. ATTRIB iNormal       = vertex.normal;
  7. ATTRIB iTex0         = vertex.texcoord[0];
  8. ATTRIB iTex1         = vertex.texcoord[1];
  9. PARAM  mvp[4]        = { state.matrix.mvp };
  10. PARAM  lightDir      = program.env[0];
  11. PARAM  eyePos        = program.env[1];
  12. PARAM  diffuse       = program.env[2];
  13. PARAM  specExp       = program.env[4];
  14. PARAM  specular      = program.env[3];
  15. PARAM  ambient       = program.env[5];
  16. PARAM  zero          = 0;
  17. PARAM  one           = 1;
  18. OUTPUT oPos          = result.position;
  19. OUTPUT oColor        = result.color;
  20. OUTPUT oSpecColor    = result.color.secondary;
  21. OUTPUT oTex0         = result.texcoord[0];
  22. OUTPUT oTex1         = result.texcoord[1];
  23. OUTPUT oNormal       = result.texcoord[2];
  24. OUTPUT oHalfAngle    = result.texcoord[3];
  25. OUTPUT oFog          = result.fogcoord;
  26.  
  27. TEMP   diffuseFactor;
  28. TEMP   eyeVec;
  29. TEMP   halfAngle;
  30. TEMP   dotProds;
  31.  
  32. # Transform the vertex by the modelview matrix
  33. DP4   oPos.x, mvp[0], iPos;
  34. DP4   oPos.y, mvp[1], iPos;
  35. DP4   oPos.z, mvp[2], iPos;
  36. DP4   oPos.w, mvp[3], iPos;
  37.  
  38. # Compute the diffuse light component
  39. DP3   diffuseFactor, iNormal, lightDir;
  40. # Clamp the diffuse component to zero
  41. MAX   diffuseFactor, diffuseFactor, zero;
  42.  
  43. # Get the vector from the eye to the vertex
  44. SUB   eyeVec, eyePos, iPos;
  45.  
  46. # Normalize it
  47. DP3   eyeVec.w, eyeVec, eyeVec;
  48. RSQ   eyeVec.w, eyeVec.w;
  49. MUL   eyeVec, eyeVec, eyeVec.w;
  50.  
  51. # Haze
  52. DP3   diffuseFactor.y, iNormal, eyeVec;
  53. SUB   diffuseFactor.y, one, diffuseFactor.y;
  54. MUL   oFog.x, diffuseFactor.x, diffuseFactor.y;
  55.  
  56. # Compute the half angle vector for specular lighting
  57. ADD   halfAngle, eyeVec, lightDir;
  58. DP3   halfAngle.w, halfAngle, halfAngle;
  59. RSQ   halfAngle.w, halfAngle.w;
  60. MUL   halfAngle, halfAngle, halfAngle.w;
  61.  
  62. # Output the texture
  63. MOV   oTex0, iTex0;
  64. MOV   oTex1, iTex1;
  65. MOV   oNormal, iNormal;
  66. MOV   oHalfAngle, halfAngle;
  67.  
  68. END
  69.